package com.scau.yangsuiyu.estore.dababases.entity;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * @author suiyu_yang
 * @description
 * @date 2019-06-13 17:57
 * @email suiyu_yang@163.com
 */
@Entity
public class Orders {
    private int id;
    private double totalPrice;
    private double paymentPrice;
    private String remark;
    private Timestamp createTime;
    private Timestamp deliveryTime;
    private Timestamp endTime;
    private String status;
    private String address;
    private Buyer buyer;


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "total_price")
    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    @Basic
    @Column(name = "payment_price")
    public double getPaymentPrice() {
        return paymentPrice;
    }

    public void setPaymentPrice(double paymentPrice) {
        this.paymentPrice = paymentPrice;
    }

    @Basic
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "delivery_time")
    public Timestamp getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(Timestamp deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    @Basic
    @Column(name = "end_time")
    public Timestamp getEndTime() {
        return endTime;
    }

    public void setEndTime(Timestamp endTime) {
        this.endTime = endTime;
    }

    @Basic
    @Column(name = "status")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Basic
    @Column(name = "address")
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "buyer_id")
    public Buyer getBuyer() {
        return buyer;
    }

    public void setBuyer(Buyer buyer) {
        this.buyer = buyer;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Orders orders = (Orders) o;
        return id == orders.id &&
                Double.compare(orders.totalPrice, totalPrice) == 0 &&
                Double.compare(orders.paymentPrice, paymentPrice) == 0 &&
                Objects.equals(remark, orders.remark) &&
                Objects.equals(createTime, orders.createTime) &&
                Objects.equals(deliveryTime, orders.deliveryTime) &&
                Objects.equals(endTime, orders.endTime) &&
                Objects.equals(status, orders.status);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, totalPrice, paymentPrice, remark, createTime, deliveryTime, endTime, status);
    }
}
